/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "MUSICGENRE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Musicgenre.findAll", query = "SELECT m FROM Musicgenre m"),
    @NamedQuery(name = "Musicgenre.findByMusicGenreId", query = "SELECT m FROM Musicgenre m WHERE m.musicGenreId = :musicGenreId"),
    @NamedQuery(name = "Musicgenre.findByMusicGenreName", query = "SELECT m FROM Musicgenre m WHERE m.musicGenreName = :musicGenreName"),
    @NamedQuery(name = "Musicgenre.findByCreatedBy", query = "SELECT m FROM Musicgenre m WHERE m.createdBy = :createdBy"),
    @NamedQuery(name = "Musicgenre.findByCreatedDate", query = "SELECT m FROM Musicgenre m WHERE m.createdDate = :createdDate"),
    @NamedQuery(name = "Musicgenre.findByModifiedBy", query = "SELECT m FROM Musicgenre m WHERE m.modifiedBy = :modifiedBy"),
    @NamedQuery(name = "Musicgenre.findByModifiedDate", query = "SELECT m FROM Musicgenre m WHERE m.modifiedDate = :modifiedDate")})
public class Musicgenre implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "MUSIC_GENRE_ID")
    private Long musicGenreId;
    @Basic(optional = false)
    @Column(name = "MUSIC_GENRE_NAME")
    private String musicGenreName;
    @Basic(optional = false)
    @Column(name = "CREATED_BY")
    private String createdBy;
    @Basic(optional = false)
    @Column(name = "CREATED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;
    @Column(name = "MODIFIED_BY")
    private String modifiedBy;
    @Column(name = "MODIFIED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date modifiedDate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "musicGenreId")
    private List<Artist> artistList;

    public Musicgenre() {
    }

    public Musicgenre(Long musicGenreId) {
        this.musicGenreId = musicGenreId;
    }

    public Musicgenre(Long musicGenreId, String musicGenreName, String createdBy, Date createdDate) {
        this.musicGenreId = musicGenreId;
        this.musicGenreName = musicGenreName;
        this.createdBy = createdBy;
        this.createdDate = createdDate;
    }

    public Long getMusicGenreId() {
        return musicGenreId;
    }

    public void setMusicGenreId(Long musicGenreId) {
        Long oldMusicGenreId = this.musicGenreId;
        this.musicGenreId = musicGenreId;
        changeSupport.firePropertyChange("musicGenreId", oldMusicGenreId, musicGenreId);
    }

    public String getMusicGenreName() {
        return musicGenreName;
    }

    public void setMusicGenreName(String musicGenreName) {
        String oldMusicGenreName = this.musicGenreName;
        this.musicGenreName = musicGenreName;
        changeSupport.firePropertyChange("musicGenreName", oldMusicGenreName, musicGenreName);
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        String oldCreatedBy = this.createdBy;
        this.createdBy = createdBy;
        changeSupport.firePropertyChange("createdBy", oldCreatedBy, createdBy);
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        Date oldCreatedDate = this.createdDate;
        this.createdDate = createdDate;
        changeSupport.firePropertyChange("createdDate", oldCreatedDate, createdDate);
    }

    public String getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(String modifiedBy) {
        String oldModifiedBy = this.modifiedBy;
        this.modifiedBy = modifiedBy;
        changeSupport.firePropertyChange("modifiedBy", oldModifiedBy, modifiedBy);
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        Date oldModifiedDate = this.modifiedDate;
        this.modifiedDate = modifiedDate;
        changeSupport.firePropertyChange("modifiedDate", oldModifiedDate, modifiedDate);
    }

    @XmlTransient
    public List<Artist> getArtistList() {
        return artistList;
    }

    public void setArtistList(List<Artist> artistList) {
        this.artistList = artistList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (musicGenreId != null ? musicGenreId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Musicgenre)) {
            return false;
        }
        Musicgenre other = (Musicgenre) object;
        if ((this.musicGenreId == null && other.musicGenreId != null) || (this.musicGenreId != null && !this.musicGenreId.equals(other.musicGenreId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.musicGenreName;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
